#include "network_context.h"

int main() {
  network::NetworkContext client("127.0.0.1", 8080,
                                 network::NetworkContext::NETWORK_PROTOCOL_TCP);

  bool isConnect = false;
  while (!isConnect) {
    if (client.StartClient() == 0) {
      int i = 1;
      const char *message = "Hello, Server!";
      char recvedMsg[512] = {0};
      while (i--) {
        client.Send(message, strlen(message));
        printf("client send: %s\n", message);
        client.Recv(recvedMsg, 512);
        printf("client received: %s\n", recvedMsg);
      }
      isConnect = true;
    }
    sleep(1);
  }

  return 0;
}
